<script>
	function search(type){
		window.location = "<?php echo base_url('/product/search')?>?type=" +type;
	}
	function login(){
		window.location = "<?php echo base_url('/user/login')?>";
	}
	function logout(){
		window.location = "<?php echo base_url('/user/logout')?>";
	}
	function regist(){
		window.location = "<?php echo base_url('/user/regist')?>";
	}
	function redirect_page_manage(){
		window.location = "<?php echo base_url('/product/search')?>";
	}
	
	function change_language(language){
		var curr_url = window.location;
		$.ajax({
			url:"<?php echo base_url('product/change_language');?>",
			data:{
				'type': language 
			},
			type: "POST",
			success:function(data){
				window.location.href = curr_url ;
			}
		});
	}
</script>
<form action ="<?php echo base_url('/product/search'); ?>" method= "get" >
<table>
	<tr>
		<td>			
			<!--  <div class ="menu"  id="menu1" style="float:left" ><a href ="<?php echo base_url('/product/home')?>">Trang Chủ<a></div>
			<div class ="menu" id="menu2" style="float:left">Thể Loại
				<div id ="menu2_child"  class ="menu_child">
					<li onclick="search(1);">Truyền Thống</li>
					<li onclick="search(2);">Cách Tân</li>
				</div>			
			</div>
			<div class ="menu"  id="menu3" style="float:left">Liên Hệ</div>
			-->
			<div class='cssmenu'>
			<ul>
			   <li class='active '><a href="<?php echo base_url('/product/home')?>"><span><?php echo lang('home')?></span></a></li>
			   <li id="menu2" ><a href='#'><span><?php echo lang('catalogue')?></span></a>
			   		<ul id ="menu2_child" class ="menu_child" >
			   			<?php	foreach ($type_aodai as $row) { ?>
			   			<li onclick="search(<?php echo $row->id ?>);"><?php  echo $language=="vietnam" ? $row->name :$row->name_eng ?></li>
						<?php }?>
			   		</ul>
			   </li>
			   <li><a href='<?php echo base_url("user/contact") ?>'><span><?php echo lang('contact')?></span></a></li>
			</ul>
			</div>
		</td>
		<td>
			<input type="text" id="txt_mahang" name="mahang" ></input>
			<select id="sel_type" name="type">
				<option id="0" value ="">--<?php echo lang('catalogue')?>-- </option>
				<?php	foreach ($type_aodai as $row) { ?>
					<option id="<?php echo $row->id?>" value ="<?php echo $row->id?>" <?php  if (isset($type) ) { echo (($type == $row->id) ?  "selected='selected'" :  "" ); }?> ><?php  echo $language=="vietnam" ? $row->name :$row->name_eng ?> </option>
				<?php }?>
				
			</select>
			<select id="sel_material" name="material">
				<option id="0" value ="">--<?php echo lang('material')?>-- </option>
				<?php foreach( $materials as $key => $value) {?>
					<option id="<?php echo $key ?>" value ="<?php echo $key ?>" > <?php echo $value?></option>
				<?php }?>
			</select>
			<input type="submit" id="btn_search" value="<?php echo lang('search')?>"></input>
		</td>
		<td>
			<?php echo isset($user_info)? lang('hello') . $user_info->username .'! <span onclick ="logout()" class="link"  >'.lang('logout').'</span>' : '<span onclick ="login()" class="link" >'.lang('login').'</span><span onclick ="regist()" class="link" > '.lang('regist').'</span>'?>
			<?php echo $is_admin == 1 ? "<br><span class=\"link\" onclick='redirect_page_manage()'>Quản lý áo dài</span>" : ''?>
			
		</td>
		<td align='right' >
			<img src="<?php echo base_url("assets/image/language/flag_vn.png")?>" onclick="change_language('vietnam')">
			<img src="<?php echo base_url("assets/image/language/flag_en.png")?>" onclick="change_language('english')">  
		</td>
	</tr>
</table>
</form>

